daemon, o/snapstate: implement snapstate.InstallPath in terms of refresh - #17166
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #17166 +/- ##
=======================================
Coverage 79.11% 79.11%
=======================================
Files 1389 1391 +2
Lines 193979 193983 +4
Branches 2466 2466
=======================================
+ Hits 153461 153465 +4
Misses 31312 31312
Partials 9206 9206
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Mon Jun 29 15:41:10 UTC 2026 Failures:Preparing:
Restoring:
Skipped tests from snapd-testing-skipIf you wish to have any of the below tests run in your PR, in your PR description, add 'unskip:' followed by a copy-and-pasted list of the below tests you wish to run (unskip plus test list must be valid yaml)
|
0894708 to
5b7a043
Compare
pedronis
left a comment
There was a problem hiding this comment.
behavior and symmetry question
| // Note that the state must be locked by the caller. | ||
| // The provided SideInfo can contain just a name which results in a | ||
| // local revision and sideloading, or full metadata in which case it | ||
| // the snap will appear as installed from the store. |
There was a problem hiding this comment.
the comment here probably needs to explain the behavioral differences between this and InstallOne with PathInstallGoal or maybe the issue is that we want InstallOne with that to also do the right thing?
There was a problem hiding this comment.
I'll update the comment on the differences, though I'm not clear on what we want InstallOne with that to also do the right thing might mean?
Do you mean that we should consider making that trigger a seed-refresh?
5b7a043 to
cf03f3b
Compare
will need to be reviewed from scratch
10e73cb to
02ffcb0
Compare
|
This PR is kinda a mixture of things now, not super focused. Though if the goal is to keep snapstate's functions more consistent, I do think they should probably be grouped together. Commits will read better than the full thing. |
02ffcb0 to
83cac3c
Compare
|
To explain the refactor a bit: I've reimplemented the current remodeling functionality that uses the Then, I've renamed some things in |
miguelpires
left a comment
There was a problem hiding this comment.
looks fine, just one question
|
Reordering some things, #17210 will get merged first. |
ab3f135 to
ee62b2c
Compare
pedronis
left a comment
There was a problem hiding this comment.
did a pass, couple of comments/questions, not sure the last rename is a pure win
| // snap state, so set that fallback before resolving. | ||
| if update.RevOpts.Channel == "" { | ||
| update.RevOpts.Channel = update.SideInfo.Channel | ||
| update.RevOpts.Channel = firstNonEmpty(update.SideInfo.Channel, trackingChannel) |
There was a problem hiding this comment.
should not this be done as some flag to resolveChannel perhaps? the comment is not super clear to me
There was a problem hiding this comment.
I'm not sure I can come up with a good name that isn't super specific to this use-case.
The issue is that we use this RevisionOptions.resolveChannel method from here and from within the store-based goals. In the store based goals, we skip the initial channel resolution during by-revision actions, since we can't know what channel to send to the store. We have a secondary resolution phase after we've finished talking to the store:
snapd/overlord/snapstate/target.go
Lines 202 to 219 in 60ca9aa
We should not skip resolution here, since we want to either take what is given to us, or use the already tracked channel. There isn't a secondary resolution phase for by-path installs, so we have to make the decision here.
Something like forceChannelResolution bool could work? Let me know and I'll make that change, but whatever we do here will be a bit confusing, in my opinion.
There was a problem hiding this comment.
the problem I have is that this new logic is called for all the cases targetForPathSnap is called but afaik there's a clear need only for seedingGoal, it's hard to reason if this is correct for the other case or not, or am I reading the changes wrong?
There was a problem hiding this comment.
Talked in person, will rename some methods on RevisionOptions and then add explicit test for PathUpdateGoal that sets a RevisionOpts.Revision.
There was a problem hiding this comment.
Both are done now.
| } | ||
|
|
||
| // InstallPath returns a set of tasks for installing a snap from a file path. | ||
| // UpdatePath returns a set of tasks for updating a snap from a file path. |
There was a problem hiding this comment.
I'm not sure the rename is that useful, I think maybe we should just be clearer in the doc comment of the function that this is able also to update snap if it's already installed
There was a problem hiding this comment.
I dropped the commit with the rename and updated the comment.
ee62b2c to
e7b8f9e
Compare
This lets us use the existing seed-refresh implementation for free during single-path installation. Tests are added for this behavior.
This makes the intent clearer, since it is only used during seeding now. Options.Seed is pretty lame though, now.
e7b8f9e to
08849e0
Compare
| // snap state, so set that fallback before resolving. | ||
| if update.RevOpts.Channel == "" { | ||
| update.RevOpts.Channel = update.SideInfo.Channel | ||
| update.RevOpts.Channel = firstNonEmpty(update.SideInfo.Channel, trackingChannel) |
There was a problem hiding this comment.
the problem I have is that this new logic is called for all the cases targetForPathSnap is called but afaik there's a clear need only for seedingGoal, it's hard to reason if this is correct for the other case or not, or am I reading the changes wrong?
…ed revision in PathUpdateGoal
pedronis
left a comment
There was a problem hiding this comment.
question about the new test
| c.Assert(err, IsNil) | ||
| c.Check(snapsup.InstanceName(), Equals, snapName) | ||
| c.Check(snapsup.Revision(), Equals, rev) | ||
| c.Check(snapsup.SnapPath, Equals, snapPath) |
There was a problem hiding this comment.
do we need to assert something about channels as that was the relevant code that triggered adding this?
There was a problem hiding this comment.
I added an assertion that ensures we retain the tracked channel in this case.
…installed revision in PathUpdateGoal
This lets us use the existing seed-refresh implementation for free during single-path installation. Tests are added for this behavior.